﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace diagnostic_extensions_console
{
    public static class DapperService
    {
        /// <summary>
        /// 因为MySql.Data.MySqlClient没有实现diagnostic功能，所以拦截不到
        /// </summary>
        /// <param name="connStr"></param>
        /// <returns></returns>
        public static MySqlConnection GetMySqlConnection(string connStr)
        {
            var connection = new MySqlConnection(connStr);
            connection.Open();
            return connection;
        }
        /// <summary>
        /// System.Data.SqlClient支持diagnostic，所以可以拦截到数据层的监控
        /// </summary>
        /// <param name="connStr"></param>
        /// <returns></returns>
        public static SqlConnection GetSqlConnection(string connStr)
        {
            var connection = new SqlConnection(connStr);
            connection.Open();
            return connection;
        }
    }
}
